/**
 * @FileName: Job.java
 * @Author
 * @Description:
 * @Date 2016年3月15日 上午11:07:25
 * @CopyRight ZTE Corporation
 */
package cn.hpclub.server.service.ds;

import java.util.Date;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cn.hpclub.server.model.SalesPromotion;
import cn.hpclub.server.service.ds.DateUtils.SyncParams;

public class JobByDay implements Job{

    private static Logger logger = LoggerFactory.getLogger(SalesPromotion.class);

    @Override
    public void execute(JobExecutionContext arg0) throws JobExecutionException{
        logger.debug("JobByDay.execute");
        exportDailyReward();
        exportDailyBroadband();
    }

    private void exportDailyReward(){
        if(DsPropKit.getProp().getBoolean(DsPropKit.SWITCH_DAILY_EXPORT)){
            SyncParams params = DateUtils.getLastDayParams(new Date());
            params.logTag = "同步酬金数据(前一天)";
            new ExportRewardTextData(params).exportAndUpload();
        } else{
            DsLog.log("未开启[同步每日酬金]功能，放弃任务.");
        }
    }

    private void exportDailyBroadband(){
        if(DsPropKit.getProp().getBoolean(DsPropKit.SWITCH_KD_DAILY_EXPORT)){
            SyncParams params = DateUtils.getLastDayParams(new Date());
            params.logTag = "同步宽带数据(前一天)";
            new ExportBroadbandTextData(params).exportAndUpload();
        } else{
            DsLog.log("未开启[同步每日宽带数据]功能，放弃任务.");
        }
    }
}
